{extend name="common/page"}
{block name="content"}
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名</label>
        <div class="layui-input-block">
            <input value="{$role.name}" type="text" name="name" required lay-verify="required" placeholder="请输入角色名" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <fieldset class="layui-elem-field">
        <legend>权限</legend>
        <div class="layui-field-box">
            {volist name="privilegeCategories" id="cate"}
            <div class="layui-form-item">
                <label class="layui-form-label">{$cate.name}</label>
                <div class="layui-input-block">
                    {volist name="cate.privileges" id="privilege"}
                    <input type="checkbox" name="privilege_id[{$privilege.id}]" title="{$privilege.name}" lay-skin="primary" {if in_array($privilege.id, $role.privilegeIdArr)}checked{/if}>
                    {/volist}
                </div>
            </div>
            {/volist}
        </div>
    </fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">禁用</label>
        <div class="layui-input-block">
            <input type="radio" name="disabled" value="1" title="是" {if $role.disabled == 1}checked{/if}>
            <input type="radio" name="disabled" value="2" title="否" {if $role.disabled == 2}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="note" placeholder="请输入内容" class="layui-textarea">{$role.note}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="editForm">修改</button>
        </div>
    </div>
</form>
{/block}

{block name="script"}
{__block__}
<script>
    layui.use(['form'], function () {
        $k.submit('editForm', '/role/edit/{$role.id}', function () {
            // reload category data table to refresh data
            $k.reload(parent.tableInst, '/role');
            // 关闭父级弹出层
            $k.adminClose();
        })
    })
</script>
{/block}